﻿@using PayrollExpress.Helpers;
@using PayrollExpress.Models;
@model EmployeeListModel

@Html.Partial("_BreadCrumb", Model.BreadCrumb)

@using (Html.BeginForm(BaseHelper.PageAddEditSave.EmployeesRefresh.ToString(), Model.ControllerName, null, FormMethod.Post, new { id = "saveForm" }))
{
    @Html.AntiForgeryToken()

    <fieldset>
        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="col-lg-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <div class="row">
                                <div class="col-lg-3">
                                    @Html.DropDownListFor(m => m.SelectedWorkLocationID, Model.WorkLocations, new { @class = "form-control input", @onchange = "Refresh()" })
                                    <button id="btnSearch" type="submit" class="hidden" name="command" value="Refresh"></button>
                                </div>
                                <div class="col-lg-9">
                                    @Html.ActionLink(BaseHelper.PageAction.Add.ToString(), BaseHelper.PageAddEditSave.EmployeeAddEdit.ToString(), Model.ControllerName, new { workLocationID = Model.SelectedWorkLocationID }, new { @class = "btn btn-primary" })
                                </div>
                            </div>
                        </div>
                        <div class="ibox-content">
                            <table class="table table-striped table-bordered table-hover table-List">
                                <thead class="header">
                                    <tr>
                                        <th>@MasterfileHelper.ListHeaders.EmployeeCode.ToDescription()</th>
                                        <th>@MasterfileHelper.ListHeaders.EmployeeName.ToDescription()</th>
                                        <th>@MasterfileHelper.ListHeaders.Address.ToDescription()</th>
                                        <th>@MasterfileHelper.ListHeaders.WorkLocation.ToDescription()</th>
                                        <th>@MasterfileHelper.ListHeaders.CurrentEmploymentType.ToDescription()</th>
                                        <th>@MasterfileHelper.ListHeaders.CurrentRateType.ToDescription()</th>
                                        <th>@MasterfileHelper.ListHeaders.CurrentRate.ToDescription()</th>
                                        <th>@AdministrationHelper.ListHeaders.IsActive.ToDescription()</th>
                                        <th></th>
                                        <th></th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @for (var i = 0; i < Model.ListItems.Count(); i++)
                                    {
                                        <tr>
                                            <td>@Html.DisplayFor(m => Model.ListItems[i].EmployeeCode)</td>
                                            <td>@Html.DisplayFor(m => Model.ListItems[i].EmployeeName)</td>
                                            <td>@Html.DisplayFor(m => Model.ListItems[i].Address)</td>
                                            <td>@Html.DisplayFor(m => Model.ListItems[i].WorkLocationName)</td>
                                            <td>@Html.DisplayFor(m => Model.ListItems[i].CurrentEmploymentType)</td>
                                            <td>@Html.DisplayFor(m => Model.ListItems[i].CurrentRateType)</td>
                                            <td>@Html.ValueFor(m => Model.ListItems[i].CurrentRate, "{0:#,###,##0.00}")</td>
                                            <td>@Html.DisplayFor(m => Model.ListItems[i].IsActiveYesNo)</td>
                                            <td>@Html.ActionLink(BaseHelper.Page.EmployeeContracts.ToDescription(), BaseHelper.Page.EmployeeContracts.ToString(), Model.ControllerName, new { employeeCode = Model.ListItems[i].EmployeeCode }, null)</td>
                                            <td>@Html.ActionLink(BaseHelper.PageAction.Edit.ToDescription(), BaseHelper.PageAddEditSave.EmployeeAddEdit.ToString(), Model.ControllerName, null, null, null, new { employeeCode = Model.ListItems[i].EmployeeCode }, new { @class = "btn btn-primary btn-sm" })</td>
                                        </tr>
                                    }
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </fieldset>
}

@section Styles {
    @Styles.Render("~/Content/plugins/dataTables/dataTablesStyles")
}

@section Scripts {
    @Scripts.Render("~/plugins/dataTables")

    <script type="text/javascript">

        $(document).ready(function () {
            $('.table-List').dataTable();
        });

        function Refresh() {
            document.getElementById('btnSearch').click();
        }

    </script>
}
